home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / kernel / dev / sun4c.md / devFsOpTable.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-19  |  9.2 KB  |  296 lines

  1. /* 
  2.  * devFsOpTable.c --
  3.  *
  4.  *    The operation tables for the file system devices on Sun-4 hosts.
  5.  *
  6.  * Copyright 1987, 1988 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  */
  15.  
  16. #ifndef lint
  17. static char rcsid[] = "$Header: /cdrom/src/kernel/Cvsroot/kernel/dev/sun4c.md/devFsOpTable.c,v 1.8 92/12/13 18:13:14 mgbaker Exp $ SPRITE (Berkeley)";
  18. #endif not lint
  19.  
  20.  
  21. #include <sprite.h>
  22. #include <dev.h>
  23. #include <devInt.h>
  24. #include <fs.h>
  25. #include <rawBlockDev.h>
  26. #include <devFsOpTable.h>
  27. #include <devTypes.h>
  28.  
  29. /*
  30.  * Device specific include files.
  31.  */
  32.  
  33. #include <devSyslog.h>
  34. #include <devNull.h>
  35. #include <devSCSIDisk.h>
  36. #include <devSCSITape.h>
  37. #include <devNet.h>
  38. #include <devBlockDevice.h>
  39. #include <devfb.h>
  40. #include <scsiHBADevice.h>
  41. #include <raidExt.h>
  42. #include <tty.h>
  43. #include <mouse.h>
  44. #include <devSmem.h>
  45. #include <devClientDev.h>
  46.  
  47.  
  48. static ReturnStatus nullOpenProc _ARGS_ ((Fs_Device *devicePtr,
  49.     int flags, Fs_NotifyToken notifyToken, int *flagsPtr));
  50. static ReturnStatus noOpenProc _ARGS_ ((Fs_Device *devicePtr,
  51.     int flags, Fs_NotifyToken notifyToken, int *flagsPtr));
  52. static ReturnStatus nullReadProc _ARGS_ ((Fs_Device *devicePtr,
  53.     Fs_IOParam *readPtr, Fs_IOReply *replyPtr));
  54. static ReturnStatus nullWriteProc _ARGS_ ((Fs_Device *devicePtr,
  55.     Fs_IOParam *writePtr, Fs_IOReply *replyPtr));
  56. static ReturnStatus nullCloseProc _ARGS_ ((Fs_Device *devicePtr,
  57.     int flags, int numUsers, int numWriters));
  58. static ReturnStatus nullSelectProc _ARGS_ ((Fs_Device *devicePtr,
  59.     int *readPtr, int *writePtr, int *exceptPtr));
  60. static ReturnStatus nullReopenProc _ARGS_ ((Fs_Device *devicePtr,
  61.     int numUsers, int numWriters, Fs_NotifyToken notifyToken, int *flagsPtr));
  62. static ReturnStatus noReopenProc _ARGS_ ((Fs_Device *devicePtr,
  63.     int numUsers, int numWriters, Fs_NotifyToken notifyToken, int *flagsPtr));
  64. static ReturnStatus noMmapProc _ARGS_ ((Fs_Device *devicePtr,
  65.     Address startAddr, int length, int offset, Address *newAddrPtr));
  66.  
  67.  
  68. /*
  69.  * Device type specific routine table:
  70.  *    This is for the file-like operations as they apply to devices.
  71.  *    DeviceOpen
  72.  *    DeviceRead
  73.  *    DeviceWrite
  74.  *    DeviceIOControl
  75.  *    DeviceClose
  76.  *    DeviceSelect
  77.  *    BlockDeviceAttach
  78.  *    DeviceReopen
  79.  *    DeviceMMap
  80.  */
  81.  
  82.  
  83. DevFsTypeOps devFsOpTable[] = {
  84.     /*
  85.      * Serial lines used to implement terminals.
  86.      */
  87.     {DEV_TERM,       DevTtyOpen, DevTtyRead, DevTtyWrite,
  88.              DevTtyIOControl, DevTtyClose, DevTtySelect,
  89.              DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  90.     /*
  91.      * The system error log.  If this is not open then error messages go
  92.      * to the console.
  93.      */
  94.     {DEV_SYSLOG,    Dev_SyslogOpen, Dev_SyslogRead, Dev_SyslogWrite,
  95.             Dev_SyslogIOControl, Dev_SyslogClose, Dev_SyslogSelect,
  96.             DEV_NO_ATTACH_PROC, Dev_SyslogReopen, noMmapProc},
  97.     /*
  98.      * SCSI Worm interface:  this device doesn't exist anymore.
  99.      */
  100.     {DEV_SCSI_WORM, noOpenProc, nullReadProc, nullWriteProc,
  101.             Dev_NullIOControl, nullCloseProc, nullSelectProc,
  102.             DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  103.     /*
  104.      * The following device number is unused.
  105.      */
  106.     {DEV_PLACEHOLDER_2, noOpenProc, nullReadProc, nullWriteProc,
  107.             Dev_NullIOControl, nullCloseProc, nullSelectProc,
  108.             DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  109.     /*
  110.      * New SCSI Disk interface.
  111.      */
  112.     {DEV_SCSI_DISK, DevRawBlockDevOpen, DevRawBlockDevRead,
  113.             DevRawBlockDevWrite, DevRawBlockDevIOControl, 
  114.             DevRawBlockDevClose, nullSelectProc, DevScsiDiskAttach,
  115.             DevRawBlockDevReopen, noMmapProc},
  116.     /*
  117.      * SCSI Tape interface.
  118.      */
  119.     {DEV_SCSI_TAPE, DevSCSITapeOpen, DevSCSITapeRead, DevSCSITapeWrite,
  120.             DevSCSITapeIOControl, DevSCSITapeClose, nullSelectProc,
  121.             DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  122.     /*
  123.      * /dev/null
  124.      */
  125.     {DEV_MEMORY,    nullOpenProc, Dev_NullRead, Dev_NullWrite,
  126.             Dev_NullIOControl, nullCloseProc, Dev_NullSelect,
  127.             DEV_NO_ATTACH_PROC, nullReopenProc, noMmapProc},
  128.     /*
  129.      * Xylogics 450 disk controller.
  130.      */
  131.     {DEV_XYLOGICS, noOpenProc, nullReadProc, nullWriteProc,
  132.             Dev_NullIOControl, nullCloseProc, nullSelectProc,
  133.             DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  134.     /*
  135.      * Network devices.  The unit number specifies the ethernet protocol number.
  136.      */
  137.     {DEV_NET,      DevNet_FsOpen, DevNet_FsRead, DevNet_FsWrite, 
  138.            DevNet_FsIOControl, DevNet_FsClose, DevNet_FsSelect, 
  139.            DEV_NO_ATTACH_PROC, DevNet_FsReopen, noMmapProc},
  140.     /*
  141.      * Raw SCSI HBA interface.
  142.      */
  143.     {DEV_SCSI_HBA, DevSCSIDeviceOpen, Dev_NullRead, Dev_NullWrite,
  144.             DevSCSIDeviceIOControl, DevSCSIDeviceClose,
  145.             Dev_NullSelect, DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  146.     /*  
  147.      * RAID device.
  148.      */ 
  149.     {DEV_RAID, DevRawBlockDevOpen, DevRawBlockDevRead,
  150.                     DevRawBlockDevWrite, DevRawBlockDevIOControl,
  151.                     DevRawBlockDevClose, Dev_NullSelect, DevRaidAttach,
  152.                     DevRawBlockDevReopen, noMmapProc},
  153.     /*  
  154.      * Debug device. (useful for debugging RAID device)
  155.      */ 
  156.     {DEV_DEBUG, DevRawBlockDevOpen, DevRawBlockDevRead,
  157.                     DevRawBlockDevWrite, DevRawBlockDevIOControl,
  158.                     DevRawBlockDevClose, Dev_NullSelect, DevDebugAttach,
  159.                     DevRawBlockDevReopen, noMmapProc},
  160.     /*
  161.      * Event devices for window systems.
  162.      */
  163.     {DEV_MOUSE,    DevMouseOpen, DevMouseRead, DevMouseWrite,
  164.            DevMouseIOControl, DevMouseClose, DevMouseSelect,
  165.            DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  166.     /*
  167.      * Frame buffer device.
  168.      */
  169.     {DEV_GRAPHICS, DevFBOpen, nullReadProc, nullWriteProc,
  170.            DevFBIOControl, DevFBClose, nullSelectProc,
  171.            DEV_NO_ATTACH_PROC, noReopenProc, DevFBMMap},
  172.     /*
  173.      * /dev/smem
  174.      */
  175.     {DEV_SMEM,     nullOpenProc, Dev_SmemRead, Dev_SmemWrite,
  176.                    Dev_SmemIOControl, nullCloseProc, Dev_SmemSelect,
  177.                    DEV_NO_ATTACH_PROC, nullReopenProc, noMmapProc},
  178.     /*
  179.      * /dev/audio
  180.      */
  181.     {DEV_AUDIO,    noOpenProc, nullReadProc, nullWriteProc,
  182.            Dev_NullIOControl, nullCloseProc, nullSelectProc,
  183.            DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  184.     /*
  185.      * /dev/vmelink
  186.      */
  187.     {DEV_VMELINK,  noOpenProc, nullReadProc, nullWriteProc,
  188.            Dev_NullIOControl, nullCloseProc, nullSelectProc,
  189.            DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  190.     /*
  191.      * /dev/stdfb
  192.      */
  193.     {DEV_STDFB,    noOpenProc, nullReadProc, nullWriteProc,
  194.            Dev_NullIOControl, nullCloseProc, nullSelectProc,
  195.            DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  196.     /*
  197.      * /dev/nothing
  198.      */
  199.     {DEV_PLACEHOLDER_4,noOpenProc, nullReadProc, nullWriteProc,
  200.            Dev_NullIOControl, nullCloseProc, nullSelectProc,
  201.            DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  202.     /*
  203.      * /dev/nothing
  204.      */
  205.     {DEV_PLACEHOLDER_5,noOpenProc, nullReadProc, nullWriteProc,
  206.            Dev_NullIOControl, nullCloseProc, nullSelectProc,
  207.            DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  208.     /*
  209.      * /dev/robot
  210.      */
  211.     {DEV_SCSI_ROBOT,noOpenProc, nullReadProc, nullWriteProc,
  212.            Dev_NullIOControl, nullCloseProc, nullSelectProc,
  213.            DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  214.     /*
  215.      * /dev/xbus
  216.      */
  217.     {DEV_XBUS,     noOpenProc, nullReadProc, nullWriteProc,
  218.            Dev_NullIOControl, nullCloseProc, nullSelectProc,
  219.            DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  220.     /*
  221.      * /dev/clients
  222.      */
  223.     {DEV_CLIENT_STATE,  DevClientStateOpen, DevClientStateRead,
  224.            DevClientStateWrite,
  225.            DevClientStateIOControl, DevClientStateClose,
  226.            nullSelectProc, DEV_NO_ATTACH_PROC,
  227.            noReopenProc, noMmapProc},
  228. };
  229.  
  230. int devNumDevices = sizeof(devFsOpTable) / sizeof(DevFsTypeOps);
  231.  
  232. static ReturnStatus
  233. nullOpenProc _ARGS_ ((Fs_Device *devicePtr,
  234.     int flags, Fs_NotifyToken notifyToken, int *flagsPtr))
  235. {
  236.     return SUCCESS;
  237. }
  238.  
  239. static ReturnStatus
  240. noOpenProc _ARGS_ ((Fs_Device *devicePtr,
  241.     int flags, Fs_NotifyToken notifyToken, int *flagsPtr))
  242. {
  243.     return FS_INVALID_ARG;
  244. }
  245.  
  246. static ReturnStatus
  247. nullReadProc _ARGS_ ((Fs_Device *devicePtr,
  248.     Fs_IOParam *readPtr, Fs_IOReply *replyPtr))
  249. {
  250.     return SUCCESS;
  251. }
  252.  
  253. static ReturnStatus
  254. nullWriteProc _ARGS_ ((Fs_Device *devicePtr,
  255.     Fs_IOParam *readPtr, Fs_IOReply *replyPtr))
  256. {
  257.     return SUCCESS;
  258. }
  259.  
  260. static ReturnStatus
  261. nullCloseProc _ARGS_ ((Fs_Device *devicePtr,
  262.     int flags, int numUsers, int numWriters))
  263. {
  264.     return SUCCESS;
  265. }
  266.  
  267. static ReturnStatus
  268. nullSelectProc _ARGS_ ((Fs_Device *devicePtr,
  269.     int *readPtr, int *writePtr, int *exceptPtr))
  270. {
  271.     return SUCCESS;
  272. }
  273.  
  274. static ReturnStatus
  275. nullReopenProc _ARGS_ ((Fs_Device *devicePtr,
  276.     int numUsers, int numWriters, Fs_NotifyToken notifyToken, int *flagsPtr))
  277. {
  278.     return SUCCESS;
  279. }
  280.  
  281. static ReturnStatus
  282. noReopenProc _ARGS_ ((Fs_Device *devicePtr,
  283.     int numUsers, int numWriters, Fs_NotifyToken notifyToken, int *flagsPtr))
  284. {
  285.     return FS_INVALID_ARG;
  286. }
  287.  
  288. static ReturnStatus
  289. noMmapProc _ARGS_ ((Fs_Device *devicePtr,
  290.     Address startAddr, int length, int offset, Address *newAddrPtr))
  291. {
  292.     return FS_INVALID_ARG;
  293. }
  294.  
  295.  
  296.